function acc = libsvmtrain_fv(lbl, data, arg, settings, ind)
dataname = [settings.title,'_',num2str(ind),'.train'];
libsvmwrite(dataname, lbl, sparse(data));
cmd = [settings.svmtrain,' ', arg, ' ',dataname,];
if settings.verbose >= 2
    disp(cmd);
end
[e, w] = system(cmd);
if settings.verbose >= 2
    disp(w);
end
if e ~= 0
    warning([num2str(ind),': Execution failed with error code: ',num2str(e)]);
    acc = 0;
    return;
end
%fclose('all');
delete(dataname);
v1 = 'Cross Validation Accuracy = ';
v2 = '%';
a1 = strfind(w, v1);
a2 = strfind(w, v2);
if (isempty(a1) || isempty(a2))
    error(['Parse output of svmtrain failed, cannot find ',v1, ' or ',v2,'.']);
end
s = w(a1(1)+length(v1):a2(1)-1);
acc = str2double(s) / 100;
end
